import {actionTypes} from './index'
import http from '@/http'

const updateHomeData = (value) => ({
    type: actionTypes.UPDATE_HOME_DATA,
    value
})
export const requestList = (showLoading = true) => {
    return (dispatch) => {
        http.get('/home/homeRefresh', {}, showLoading).then(
            res => {
                if (res.status === 1) {
                    dispatch(updateHomeData(res.data.formData))
                }
                let timer = setTimeout(function () {
                    dispatch(requestList(false))
                    dispatch(changeTimer(timer))
                }, 3000)
            })
    }
}

export const changeTimer = (value) => ({
    type: actionTypes.CHANGE_TIMER,
    value
})
